package com.youmeek.ssm.module.user.service.impl;

import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;

import com.youmeek.ssm.module.user.pojo.Page;
import com.youmeek.ssm.module.user.pojo.Supplier;
import com.youmeek.ssm.module.user.mapper.SupplierDao;

@Service
public class SupplierService{

    @Resource
    private SupplierDao supplierDao;

    public int insert(Supplier pojo){
        return supplierDao.insert(pojo);
    }

    public int insertSelective(Supplier pojo){
        return supplierDao.insertSelective(pojo);
    }

    public int insertList(List<Supplier> pojos){
        return supplierDao.insertList(pojos);
    }

    public int update(Supplier pojo){
        return supplierDao.update(pojo);
    }

    public Page<Supplier> selectPage(Page<Supplier> page){
        List<Supplier> sl = supplierDao.selectList(page);
//        page.setList(supplierDao.selectList(page));
        System.out.println("记录条数: "+sl.size());
        page.setList(sl);
        page.setTotal(supplierDao.selectTotal(page));
        System.out.println("总数是："+page.getTotal());
        return page;
    }

    /**
     * @param pks 1. 这里接受一个数组对象作为参数
     *            2. mapper.xml中并没有配置 sql 接受的参数类型
     *
     */
    public int deleteByPks(String[] pks){
        return supplierDao.deleteByPks(pks);
    }


    public int insert(){
        return 0;
    }
}
